package com.xuan.webfinally.mapper;

import com.xuan.webfinally.entity.SlopeGeoacousticData;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xuan.webfinally.entity.pax4;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 地声传感器监测数据表 Mapper 接口
 * </p>
 *
 * @author gyuxuan
 * @since 2025-09-08
 */
public interface SlopeGeoacousticDataMapper extends BaseMapper<SlopeGeoacousticData> {

    @Select("SELECT device_sn, monitor_id,original_sound_pressure, effective_sound_pressure, " +
            "frequency_signal, create_time, update_time " +
            "FROM (" +
            "    SELECT *, " +
            "    ROW_NUMBER() OVER (PARTITION BY device_sn ORDER BY update_time DESC) AS rn " +
            "    FROM slope_geoacoustic_data " +
            "    WHERE slope_id = #{deptId} " +
            ") t " +
            "WHERE rn = 1")
    List<pax4> selectPax4List(String deptId);
}
